package com.liaoye.hellocustomview.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;

public class PaintView3 extends View {

    private static final String TAG = PaintView3.class.getSimpleName();

    public PaintView3(Context context) {
        super(context);
    }

    public PaintView3(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public PaintView3(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        Path path = new Path();
        path.moveTo(100, 300);


        // 二阶贝塞尔曲线 (xl ,y1)是控制点坐标，（x2,y2）是终点坐标
        path.quadTo(200, 200, 300, 300);
        path.quadTo(400, 400, 500, 300);

        // 二阶贝塞尔曲线 xl ,y1是控制点相对于上个终点坐标得值，x2,y2是终点坐标相对于上个终点坐标的值
        path.rQuadTo(100, -100, 300, 300);
        path.quadTo(400, 400, 500, 300);

        Paint paint = new Paint();
        paint.setColor(Color.BLACK);
        paint.setStrokeWidth(2);
        paint.setStyle(Paint.Style.STROKE);
        canvas.drawPath(path, paint);


    }
}
